#define _CRT_SECURE_NO_WARNINGS 1
class Solution {

public:

    ListNode* middleNode(ListNode* head) {

        if (head == nullptr) return head;

        ListNode* slow = head;

        ListNode* fast = head;

        while (fast->next != nullptr)

        {

            slow = slow->next;

            fast = fast->next->next;

            if (fast == nullptr) break;

        }

        return slow;



    }

};